#e
#Title[ؕuVtBEBXp[v]
#Text[]
#Player[FREE]
#Image[.]
#BackGround[User]
#ScriptVersion[2]
script_enemy_main {

let Norma=4;//Be̐ݒ
let SpellTimer=9000;//Ԃ̐ݒit[Pʁj
let StepUp=[2];//iKڍs閇ݒi܂܂Őݒ\jBStepUp1`5ibooleanj܂łA͖BtrueɂȂ

#include_function ".\..\txt/DoubleSpoilerData.txt"

    let imgBoss =GetCurrentScriptDirectory ~ "..\lib/dot_patchouli.png"; 

    // ʒu
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 112;


   @Initialize {
	SetShotAutoDeleteClip(8,8,8,8);
	InitializeDoubleSpoiler;
	DrawSpellName(imgSpellName,9,7,365,33);
        LoadGraphic(imgBoss);
        SetTexture(imgBoss);
	InitializeAction();
	SetX(xIni);
	SetY(yIni);
        TMain;
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	DoubleSpoilerYield;
    }

let appearecount=0;

    @DrawLoop {
	if(appearecount<30)
	{
	appearecount+=1;
	}
	SetAlpha(255/30*appearecount);
	DrawBossAndShadow( imgBoss,255,0,255);
	DrawBoss( imgBoss );
    }

    @Finalize {
        DeleteGraphic(imgBoss);
	FinalizeDoubleSpoiler;
    }
	@BackGround
	{

	}

    // C^XN
task TMain 
{
	yield;
	BossShadowPosition(0);
	standBy;
	TMove;
	Shot;
	Shot2;	
}

sub standBy//ʒu
{
	AppearEffect;
	let wIni = 30;
	wait(wIni);
}

task TMove// gƈړ
{
	loop
	{
	let angle=0;
	let y =GetY;
	loop(120)
	{
		SetY(y+4*sin(angle));
		yield;
		angle+=3;
	}
	DoubleSpoilermoveToPlayer(rand(40, 60), rand(-30, 30), 30,
                     GetClipMinX + 48, GetClipMinY +  80,
                     GetClipMaxX - 48, GetClipMinY + 144);
	MagicCircleEffectTask;
	}
}

task AppearEffect
{
		let Scale=0.5;
		let Zangle=0;
		let Xangle=0;
  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,GetX,GetY);
		ObjEffect_SetTexture(obj,DoubleSpoilerimgCircle);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_SetScale(obj, Scale,Scale);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -128, -128);
		ObjEffect_SetVertexXY(obj, 1,  128, -128);
		ObjEffect_SetVertexXY(obj, 2,  128,  128);
		ObjEffect_SetVertexXY(obj, 3, -128,  128);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  256, 0);
		ObjEffect_SetVertexUV(obj, 2, 256,  256);
		ObjEffect_SetVertexUV(obj, 3, 0, 256);
		loop(30)
		{
			Xangle+=3;
			Zangle+=6;
			ObjEffect_SetAngle(obj,Xangle,0,Zangle);
			yield;
		}
		Obj_Delete(obj);
}

task Shot2
{
while(!StepUp1){yield;}
let w=90;
let dir=1;
	loop
	{
		loop(7)
		{
			SetShotColor(200,255,200);
			DoubleSpoilerCreateShot01(rand(GetClipMinX-64,GetClipMaxX+64), GetClipMinY,rand(2,3),w,GREEN11,30,SetBulletColor[3],0,2);
			SetShotColor
(255,255,255);
		}
		if(w<=170 && dir==1)
		{
			w+=4;
		}
		if(w>=10 && dir==-1)
		{
			w-=4;
		}
		if(w>=170)
		{
			dir=-1;
			wait(30);
		}
		if(w<=10)
		{
			dir=1;
			wait(30);
		}
	wait(6);
	}
}

task Shot
{
let w=90;
let dir=1;
	loop
	{
		loop(8)
		{
			DoubleSpoilerCreateShot01(rand(GetClipMinX-64,GetClipMaxX+64), GetClipMinY,rand(2,3),w,GREEN11,30,SetBulletColor[3],0,2);
		}
		if(w<=170 && dir==1)
		{
			w+=4;
		}
		if(w>=10 && dir==-1)
		{
			w-=4;
		}
		if(w>=170)
		{
			dir=-1;
			wait(30);
		}
		if(w<=10)
		{
			dir=1;
			wait(30);
		}
	wait(4);
	}
}

#include_function ".\..\txt/Data.txt"
#include_function ".\..\lib/lib_anime_Patchouli.txt"
}
